package com.cskaoyan.crud;

import com.cskaoyan.utils.JDBCUtils;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * 创建日期: 2022/07/26 10:11
 *
 * @author ciggar
 */
public class UpdateDemo {

    public static void main(String[] args) throws SQLException {


        // 获取连接
        Connection connection = JDBCUtils.getConnection();

        // 获取statement
        Statement statement = connection.createStatement();

        // 执行SQL语句
        int affectedRows = statement.executeUpdate("update student set name= '道姑', gender = '女' where id > 1002");


        System.out.println("affectedRows:" + affectedRows);


        // 关闭资源
        JDBCUtils.closeResource(statement,connection);


    }
}
